package com.example.hellodemo.listView;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.hellodemo.R;


public class GrideViewActivity extends AppCompatActivity {
    private GridView grideView;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gride);
        grideView = findViewById(R.id.griderecycleView);
        grideView.setAdapter(new GrideAdapter(GrideViewActivity.this));

        grideView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(GrideViewActivity.this,"第几个："+ position,Toast.LENGTH_SHORT).show();
            }
        });

    }
}
